home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dev / insight_dev.idb / usr / share / Insight / bin / convert_helpmap.z / convert_helpmap
Encoding:
Text File  |  2002-10-16  |  2.6 KB  |  113 lines

  1. #!/usr/bin/perl
  2. #
  3. # Copyright 2002, Silicon Graphics, Inc.
  4. # All Rights Reserved.
  5. #
  6. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  7. # the contents of this file may not be disclosed to third parties, copied or
  8. # duplicated in any form, in whole or in part, without the prior written
  9. # permission of Silicon Graphics, Inc.
  10. #
  11. # RESTRICTED RIGHTS LEGEND:
  12. # Use, duplication or disclosure by the Government is subject to restrictions
  13. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  14. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  15. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  16. # rights reserved under the Copyright Laws of the United States.
  17. #
  18. # ---------------
  19. # convert_helpmap
  20. # ---------------
  21. # syntax:
  22. #
  23. #    convert_helpmap <bkshlf> <bk> <toc_file> <helpmap_file>
  24. #
  25.  
  26. $SHLF = $ARGV[0];
  27. $BK   = $ARGV[1];
  28. $TOC  = $ARGV[2];
  29. $HMAP = $ARGV[3];
  30.  
  31. if ($SHLF eq '' || $BK eq '' || $TOC eq '' || $HMAP eq '') {
  32.     &usage("bookshlf, book, toc_file, or helpmap_file not specified");
  33. }
  34. if (!(-f $TOC) || !(-f $HMAP)) {
  35.     &usage("TOC file (${TOC}) or helpmap file (${HMAP}) not found");
  36. }
  37.  
  38. my(@hl, @pts) = ();
  39. my(%toc_pts) = ();
  40. my($f, $s) = '';
  41.  
  42. # open existing helpmap, read in all points
  43. #
  44. open(HELPMAP, "${HMAP}") || &usage("Cannot open helpmap: ${HMAP}");
  45. @hl = <HELPMAP>;
  46. close(HELPMAP);
  47.  
  48.  
  49. # open toc file, get new points
  50. #
  51. my($help_fnd) = 0;
  52. open(TOCF, "${TOC}") || &usage("Cannot open TOC: ${TOC}");
  53. while(<TOCF>) {
  54.  
  55.      chop;
  56.  
  57.      if ($help_fnd == 0) {
  58.          if ($_ =~ /^\#[\s]+help/i) {
  59.              $help_fnd = 1;
  60.          }
  61.          next;
  62.      }
  63.  
  64.      @pts = split(/\|/, $_);
  65.      if ($pts[3] ne '' && $pts[2] ne '') {
  66.          $toc_pts{$pts[3]} = $pts[2];
  67.      }
  68. }
  69. close(TOCF);
  70.  
  71.  
  72. # open new/revised helpmap which we will write to
  73. #
  74. open(HM_REV, "> ${HMAP}.rev") || &usage("Cannot open helpmap: ${HMAP}.rev");
  75.  
  76. # check helpmap points
  77. #
  78. foreach $s (@hl) {
  79.  
  80.    if ($s !~ /\;/ || $s =~ /^\#/ || length($s) <= 1) {
  81.        print HM_REV $s; 
  82.        next;
  83.    }
  84.  
  85.    @pts = split(/\;/, $s);
  86.  
  87.    if ($pts[1] =~ /^HREF/i) {
  88.        print HM_REV $s; 
  89.        next;
  90.    }
  91.  
  92.    if (($f = $toc_pts{$pts[4]}) ne '') {
  93.         $pts[1] = "HREF=file:/usr/share/Insight/library/SGI_bookshelves/" .
  94.                   "${SHLF}/books/${BK}/sgi_html/${f}";
  95.  
  96.         print HM_REV join(';', @pts);
  97.    }
  98. }
  99. close(HM_REV);
  100. print "\nconvert_helpmap: revised helpmap - ${HMAP}.rev\n";
  101.  
  102. exit 0;
  103.  
  104.  
  105. sub usage {
  106.  
  107.     my($err) = @_;
  108.     print "\nusage: convert_helpmap <bkshlf> <bk> <toc_file> <helpmap_file>\n", 
  109.           ($err ne '' ? "${err}\n" : '');
  110.     exit(-1);
  111. }
  112.  
  113.